MASK = (1 << 32) - 1


def add(a, b) -> int:
    if b == 0: return a
    return add((a ^ b) & MASK, ((a & b) << 1) & MASK)


def minus(a, b) -> int:
    return add(a, ~b + 1)


def mut(a, b):
    ans = 0
    while b:
        if b & 1:
            ans = add(ans, a)
        a <<= 1
        b >>= 1
    return ans


def div(a, b) -> int:
    ans = 0
    for i in range(30, -1, -1):
        if (a >> i) >= b:
            ans |= (1 << i)
            a = minus(a, (b << i))
    return ans


if __name__ == '__main__':
    print(mut(3, 5))
    print(div(60, 2))
